package cn.hlife.com.hlfhaemocyte.utils;

import android.content.Context;
import android.content.SharedPreferences;

/**
 * Created by Administrator on 2017/6/14.
 */

public class SharedPreferencesUtils {
    public final String HAEMOCYTE = "haemocyte";
    public final String FullBlood_ParameterKEY = "FullBlood_ParameterKEY";//全血参数相关的Key
    public final String Diluent_ParameterKEY = "Diluent_ParameterKEY";//预稀释参数相关的Key
    public final String BluetoothMAC = "BluetoothMAC";//蓝牙的MAC地址
    public final String Maintain = "Maintain";//维护功能中的参数
    public final String ChartKEY="ChartKEY";//图表数据
    public final String ReportReference="ReportReference";//图表数据
    public final String YXSReference="YXSReference";//预稀释相关
    public final String SYSMODE="SYSMODE";//系统模式
    public static SharedPreferencesUtils getInstance() {
        return SharedPreferencesUtils.SharedPreferencesUtilsHelp.inStance;
    }

    static class SharedPreferencesUtilsHelp {
        static SharedPreferencesUtils inStance = new SharedPreferencesUtils();
    }

    /*
    *保存全血模式相关的细胞参数
     */
    public void saveFullBloodCellParameter(Context context, String value) {
        SharedPreferences preferences = context.getSharedPreferences(HAEMOCYTE,
                Context.MODE_PRIVATE);
        preferences.edit().putString(FullBlood_ParameterKEY, value).commit();
    }

    /*
    *读取全血模式相关的细胞参数
    */
    public String getFullBloodCellParameter(Context context) {
        SharedPreferences preferences = context.getSharedPreferences(HAEMOCYTE,
                Context.MODE_PRIVATE);
        return preferences.getString(FullBlood_ParameterKEY, "");
    }

    /*
*保存预稀释模式相关的细胞参数
 */
    public void saveDiluentCellParameter(Context context, String value) {
        SharedPreferences preferences = context.getSharedPreferences(HAEMOCYTE,
                Context.MODE_PRIVATE);
        preferences.edit().putString(Diluent_ParameterKEY, value).commit();
    }

    /*
    *读取预稀释模式相关的细胞参数
    */
    public String getDiluentCellParameter(Context context) {
        SharedPreferences preferences = context.getSharedPreferences(HAEMOCYTE,
                Context.MODE_PRIVATE);
        return preferences.getString(Diluent_ParameterKEY, "");
    }

//    /**
//     * 获取机位指令相关参数
//     */
//    public String getMachineCommandAbout(Context context) {
//        SharedPreferences preferences = context.getSharedPreferences(HAEMOCYTE,
//                Context.MODE_PRIVATE);
//        return preferences.getString(MachineCommand, "");
//    }
//
//    /**
//     * 设置机位指令相关参数
//     */
//    public void setMachineCommandAbout(Context context, String value) {
//        SharedPreferences preferences = context.getSharedPreferences(HAEMOCYTE,
//                Context.MODE_PRIVATE);
//        preferences.edit().putString(MachineCommand, value).commit();
//    }

    /**
     * 保存蓝牙MAC地址
     */
    public void saveBluetoothAddress(Context context, String value) {
        SharedPreferences preferences = context.getSharedPreferences(HAEMOCYTE,
                Context.MODE_PRIVATE);
        preferences.edit().putString(BluetoothMAC, value).commit();
    }

    /**
     * 读取蓝牙MAC地址
     */
    public String getBluetoothAddress(Context context) {
        SharedPreferences preferences = context.getSharedPreferences(HAEMOCYTE,
                Context.MODE_PRIVATE);
        return preferences.getString(BluetoothMAC, "");
    }

    /**
     * 保存维护功能的相关参数
     */
    public boolean saveMaintainParameter(Context context, String value) {
        SharedPreferences preferences = context.getSharedPreferences(HAEMOCYTE,
                Context.MODE_PRIVATE);
        return preferences.edit().putString(Maintain, value).commit();
    }

    /**
     * 读取维护功能的相关参数
     */
    public String getMaintainParameter(Context context) {
        SharedPreferences preferences = context.getSharedPreferences(HAEMOCYTE,
                Context.MODE_PRIVATE);
        return preferences.getString(Maintain, "");
    }

    /**
     * 保存维护功能的相关参数
     */
    public boolean saveChartParameter(Context context, String value) {
        SharedPreferences preferences = context.getSharedPreferences(HAEMOCYTE,
                Context.MODE_PRIVATE);
        return preferences.edit().putString(ChartKEY, value).commit();
    }

    /**
     * 读取维护功能的相关参数
     */
    public String getChartParameter(Context context) {
        String  tem="{\"WN13\":\"1\",\"WN12\":\"1\",\"WN15\":\"1\",\"WN14\":\"1\",\"WN17\":\"1\",\"WN16\":\"1\",\"WN19\":\"1\",\"WN18\":" +
                "\"1\",\"WN6\":\"1\",\"WN5\":\"1\",\"WN4\":\"1\",\"WN3\":\"1\",\"WN2\":\"1\",\"WN1\":\"1\",\"WN11\":" +
                "\"1\",\"WN10\":\"1\",\"PN13\":\"1\",\"PN14\":\"1\",\"PN15\":\"1\",\"RN9\":\"1\",\"PN16\":\"1\",\"RN8\":\"1\",\"PN17\":" +
                "\"1\",\"RN7\":\"1\",\"PN18\":\"1\",\"RN6\":\"1\",\"PN19\":\"1\",\"RN5\":\"1\",\"RN4\":\"1\",\"RN20\":\"1\",\"RN3\":\"1\",\"RN2\":" +
                "\"1\",\"RN1\":\"1\",\"PN4\":\"1\",\"RN18\":\"1\",\"PN5\":\"1\",\"RN17\":\"1\",\"PN2\":\"1\",\"RN16\":\"1\",\"PN3\":\"1\",\"RN15\":" +
                "\"1\",\"PN1\":\"1\",\"RN19\":\"1\",\"PN8\":\"1\",\"PN20\":\"1\",\"PN9\":\"1\",\"PN6\":\"1\",\"PN7\":\"1\",\"WN20\":\"1\",\"RN10\":" +
                "\"1\",\"RN11\":\"1\",\"RN12\":\"1\",\"RN13\":\"1\",\"RN14\":\"1\",\"WN7\":\"1\",\"WN8\":\"1\",\"WN9\":\"1\",\"PN12\":\"1\",\"PN11\":" +
                "\"1\",\"PN10\":\"1\"}";
        SharedPreferences preferences = context.getSharedPreferences(HAEMOCYTE,
                Context.MODE_PRIVATE);
        return preferences.getString(ChartKEY, tem);
    }
    /**
     * 保存参考值的设置
     */
    public boolean saveReportRefernce(Context context, String value) {
        SharedPreferences preferences = context.getSharedPreferences(HAEMOCYTE,
                Context.MODE_PRIVATE);
        return preferences.edit().putString(ReportReference, value).commit();
    }

    /**
     * 读取参考值的设置
     */
    public String getReportRefernce(Context context) {
        SharedPreferences preferences = context.getSharedPreferences(HAEMOCYTE,
                Context.MODE_PRIVATE);
        return preferences.getString(ReportReference, "{\"PLCR\":\"\",\"MCH\":\"\",\"GRAP\":\"\",\"GRA\":\"\",\"MON\":\"\",\"LYM\":\"\",\"MPV\":\"\",\"MCHC\":\"\",\"PLTY\":\"\",\"MONP\":\"\",\"HCT\":\"\",\"HGB\":\"\",\"LYMP\":\"\",\"PDWSD\":\"\",\"PDW\":\"\",\"MCV\":\"\",\"RBC\":\"\",\"PDWCV\":\"\",\"PLT\":\"\",\"WBC\":\"\"}");
    }
    /**
     * 保存预稀释的设置
     */
    public boolean saveYXSRefernce(Context context, String value) {
        SharedPreferences preferences = context.getSharedPreferences(HAEMOCYTE,
                Context.MODE_PRIVATE);
        return preferences.edit().putString(YXSReference, value).commit();
    }

    /**
     * 读取预稀释直方图的设置
     */
    public String getYXSRefernce(Context context) {
        SharedPreferences preferences = context.getSharedPreferences(HAEMOCYTE,
                Context.MODE_PRIVATE);
        return preferences.getString(YXSReference, "");
    }
    /**
     * 保存设置模式
     */
    public boolean saveMode(Context context, String value) {
        SharedPreferences preferences = context.getSharedPreferences(HAEMOCYTE,
                Context.MODE_PRIVATE);
        return preferences.edit().putString(SYSMODE, value).commit();
    }

    /**
     * 读取设置模式
     */
    public String getMode(Context context) {
        SharedPreferences preferences = context.getSharedPreferences(HAEMOCYTE,
                Context.MODE_PRIVATE);
        return preferences.getString(SYSMODE, "");
    }

}
